package com.example.administrator.myapplication.View.Fragment;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.example.administrator.myapplication.Bean.Notice;
import com.example.administrator.myapplication.Presenter.NoticePresenter;
import com.example.administrator.myapplication.R;
import com.example.administrator.myapplication.View.Activity.NoticeActivity;
import com.example.administrator.myapplication.View.layout.NoticeItemView;

import java.util.List;

/**
 * Created by Administrator on 2019/10/13 0013.
 */

public class NoticeFragment extends Fragment implements NoticeItemView.OnRootClickListener{
    private NoticePresenter noticePresenter;
    private LinearLayout ll_root;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_notice,container,false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        init(view);
    }
    private void init(View view){
        ll_root = view.findViewById(R.id.ll_root);
        ll_root.addView(new NoticeItemView(getContext())
                .init(R.drawable.splash,"通知类消息","","",true)
                .setOnRootClickListener(this,1)
        );
        ll_root.addView(new NoticeItemView(getContext())
                .init(R.drawable.splash,"公告类消息","","",true)
                .setOnRootClickListener(this,2)
        );
    }

    @Override
    public void onRootClick(View view) {
        Intent intent;
        switch ((int)view.getTag()){
            case 1:
                intent = new Intent(getActivity(), NoticeActivity.class);
                intent.putExtra("title","通知类消息");
                intent.putExtra("type","1");
                startActivity(intent);
                break;
            case 2:
                intent = new Intent(getActivity(), NoticeActivity.class);
                intent.putExtra("title","公告类消息");
                intent.putExtra("type","2");
                startActivity(intent);
                break;
        }
    }
}
